﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;

namespace Craw
{
    public partial class FormMain : Form
    {
        String PageUrl;

        public FormMain()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            /*
             * 
            PageUrl = UrlText.Text;
            WebRequest request = WebRequest.Create(PageUrl);
            WebResponse response = request.GetResponse();
            Stream resStream = response.GetResponseStream();
            StreamReader sr = new StreamReader(resStream, System.Text.Encoding.Default);
            ContentHtml.Text = sr.ReadToEnd();
            resStream.Close();
            sr.Close();
            ContentHtml.Text = Regex.Replace(ContentHtml.Text, "<[^>]*>", "");
            //替换空格
            ContentHtml.Text = Regex.Replace(ContentHtml.Text, "\\s+", " ");
            
             * */

        }

        public void addListViewItem(JobDTO val)
        {
            ListViewItem item = new ListViewItem(val.Name);
            item.Tag = val;

            ListViewItem.ListViewSubItem s1 = new ListViewItem.ListViewSubItem(item, "启动");
            ListViewItem.ListViewSubItem s2 = new ListViewItem.ListViewSubItem(item, val.Status.ToString());
           

            item.SubItems.Add(s1);
            item.SubItems.Add(s2);

            listView1.Items.Add(item);
        }

        private void tabControlTree_SelectedIndexChanged(object sender, EventArgs e)
        {
            
        }

        private void tabControlTree_Selecting(object sender, TabControlCancelEventArgs e)
        {
            e.TabPage.Controls.Clear();
            e.TabPage.Controls.Add(this.listView1);

            if (e.TabPageIndex != 0)
            {
                this.listView1.ContextMenuStrip = null;
                foreach (ListViewItem item in listView1.Items)
                {
                    item.SubItems[1].Text = "查看";
                }
            }
            else
            {
                this.listView1.ContextMenuStrip = this.contextMenuStrip1;
                foreach (ListViewItem item in listView1.Items)
                {
                    item.SubItems[1].Text = "启动";
                }
            }
        }

        private void 新增ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.panelMain.Controls.Clear();

            UserControl1 uc = new UserControl1();
            uc.Dock = DockStyle.Fill;
            uc.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
            this.panelMain.Controls.Add(uc);
        }

        private void FormMain_Load(object sender, EventArgs e)
        {

        }

        private void FormMain_Resize(object sender, EventArgs e)
        {
            
        }

        private void listView1_Resize(object sender, EventArgs e)
        {
            
        }

        private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e)
        {

        }

        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count > 0)
            {

            }
        }
    }
}
